#include"Command.hpp"
#include"TcpServer.hpp"



void Usage(std::string proc)
{
    std::cerr << "Usage:" << proc << "port" << std::endl;
}

//远程命令执行的功能
//./tcpserver port
int main(int argc,char** argv)
{
    if(argc != 2)
    {
        Usage(argv[0]);
        exit(USAGE_ERR);
    }
    uid_t port = std::stoi(argv[1]);
    
    //开启终端策略模式
    Enable_Console_Log_Strategy();

    Command cmd;
    std::unique_ptr<TcpServer> tsvr = std::make_unique<TcpServer>(port, std::bind(&Command::Excute, &cmd, std::placeholders::_1, std::placeholders::_2));
    tsvr->Init();//等效于tsvr.operator->()->Init();
    tsvr->Run();

    return 0;
}

